package com.scetop.bank;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Customer {
    private String firstName;
    private String lastName;

//    private Account [] accounts;
//    private int numberOfAccounts;

    private List<Account> accounts;

    private SavingAccount savingsAccount;
    private CheckingAccount checkingAccount;

    // 建立了Customer类和Account类的关系
    private Account account;

    public Customer(String f, String l) {
        this.firstName = f;
        this.lastName = l;

//        accounts = new Account[10];
        accounts = new ArrayList<>();
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public void addAccount(Account account) {
//        accounts[numberOfAccounts++] = account;
        accounts.add(account);
    }

    public Account getAccount(int index) {
//        return accounts[index];
        return accounts.get(index);
    }

    public int getNumberOfAccounts() {
//        return numberOfAccounts;
        return accounts.size();
    }

    public String getFirstName() {
        return this.firstName;
    }
    public String getLastName() {
        return this.lastName;
    }
    public Account getAccount() {
        return this.account;
    }

    public SavingAccount getSavingsAccount() {
        return savingsAccount;
    }

    public void setSavingsAccount(SavingAccount savingsAccount) {
        this.savingsAccount = savingsAccount;
    }

    public CheckingAccount getCheckingAccount() {
        return checkingAccount;
    }

    public void setCheckingAccount(CheckingAccount checkingAccount) {
        this.checkingAccount = checkingAccount;
    }

    public Iterator<Account> getAccounts() {
        return accounts.iterator();
    }

}